value rounded DOWN to a whole number, toward NEGATIVE INFINITY, and handed back as a real - 1.9 becomes 1, and -1.9 becomes -2.
floor(value) -> real| Name | Type |
|---|---|
value | real |
real
value rounded DOWN to a whole number - toward NEGATIVE INFINITY, never toward zero - and handed back as a real. 3.75 becomes 3, and -3.75 becomes -4.
floor and int_floor round the same way and differ only in what they hand back. floor returns a real that happens to have nothing after the point, so it goes straight back into more real maths. int_floor returns an int, which is what you need for an array index, a count or a loop bound. The rule across the whole language is the same: a function with no prefix hands back a real, and an int_ function hands back a whole number. roll_real is the one deliberate exception and keeps its suffix.
var column_x = floor(x / 8) * 8;Snaps x down to the nearest multiple of 8 at or to its left, on both sides of zero: x = 21 gives 16, and x = -3 gives -8, not 0. There is no conversion in the middle, because floor already returns a real.
Reach for int_floor when the result means "which cell" and has to be a whole-number int - for example var column = int_floor(x / 8); to index a grid.
One call into the Game Boy Advance module's own round-down call for fixed-point numbers, then back to a real. It costs what int_floor costs.
The same rounding as int_floor (the GBA module’s own fixed-point round-down function), but the answer is a real with nothing after the point, so it can go straight back into real maths - floor(x / 8) * 8 snaps x down to a multiple of 8 with no conversion in between. Use int_floor instead when the result must be an int (an index, a count, a loop bound). A real in a 20.12 fixed-point number: its whole-number part is exact, so the result is exact too, never a nearby approximation.